import CoordinateToWebgl from './js/calculate/coordinate-to-webgl';
import Webgl from './js/render/render-webgl';
let webgl = new Webgl(document.getElementById('canvas'));

/*
  polygon test
*/

// let coordinateToWebgl = new CoordinateToWebgl();
// let data = coordinateToWebgl.polygon([
//   [0.2, 0.2, -0.2, 0.2, 0, -0.2],
//   [0.7, 0.7, -0.7, 0.7, 0.9, -0.7]
// ]);



// webgl.fillColor = 'rgba(255,0,0,1.0)';
// webgl.clearWebglCanvasStatus();
// webgl.renderPolygon(data[0]);
// webgl.fillColor = 'rgba(0,0,255,1.0)';
// let temp = [
//   [0.1, 0, 0.1, 0.4, 0.3, 0.3, 0, 0.6, -0.3, 0.3, -0.1, 0.4, -0.1, 0],
//   [0.3, 0, 0.1, 0, 0, 0.3, -0.1, 0, -0.3, 0, -0.2, -0.1, -0.3, -0.3, 0, -0.2, 0.3, -0.3, 0.2, -0.1],
//   [0.5, 0.4, 0.7, 0.4, 0.7, 0.8, 0.5, 0.8],
//   [-0.8, 0.4, -0.7, 0.4, -0.7, 0.2, -0.5, 0.2, -0.5, 0.4, -0.4, 0.4, -0.4, 0.6, -0.5, 0.6, -0.5, 0.8, -0.7, 0.8, -0.7, 0.6, -0.8, 0.6],
//   [0.5, -0.3, 0.4, -0.4, 0.55, -0.7, 0.62, -0.7, 0.7, -0.55, 0.6, -0.5, 0.65, -0.6, 0.55, -0.6]
// ]
// let data2 = coordinateToWebgl.polygon(temp);
// webgl.renderPolygon(data2[0]);
// webgl.renderPolygon(data[1]);

/**
 * text test
 */
let cxt = webgl.canvasContext;
let count = 0;
const textRotateAnimate = () => {
  webgl.clearWebglCanvasStatus();
  webgl.renderText('LUKEugasjdghajksgdjasgh', [0, 0], {
    wordWrapWidth: '80',
    font: '100 15px monospace',
    fillStyle: '#00ff00',
    rotate: Math.PI / 360 * count
  });
  count++;
  window.requestAnimationFrame(textRotateAnimate);
}
textRotateAnimate();